<%@page import="model.environment.*"%>
<%@page import="model.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page trimDirectiveWhitespaces="true" %>
    
<% 	PageViewInfo pvi = new PageViewInfo();
	pvi.setPageTitle("Basket"); %>
<%@include file="parts/header.jsp" %>
<%
ShoppingBasket basket = ShoppingBasket.getShoppingBasket(session);
Map<Integer, Integer> map = basket.getHashMap();
%>
	<div class="content">
		<h1>Basket</h1>
		<% if (map.size() == 0)
		{
			%><h2>The basket is empty.</h2><%
		}
		else
		{
			%>
			<form method="post" action="updateBasket.do">
				<div style="width:700px;">
					<div style="width:49px;border-right:1px dashed black;float:left;">
						<h2 style="text-align:center;">#</h2>
					</div>
					<div style="width:349px;border-right:1px dashed black;float:left;">
						<h2 style="text-align:center;">Name</h2>
					</div>
					<div style="width:99px;border-right:1px dashed black;float:left;">
						<h2 style="text-align:center;">Stock</h2>
					</div>
					<div style="width:99px;border-right:1px dashed black;float:left;">
						<h2 style="text-align:center;">Price</h2>
					</div>
					<div style="width:100px;float:left;">
						<h2 style="text-align:center;">Amount</h2>
					</div>
				</div>
			<%
			int count = 0;
			for (Integer i : map.keySet())
			{
				count++;
				Item item = Items.getItem(i); 
				%>
				<div style="width:700px;border-top:1px solid black;float:left;">
					<div style="width:49px;border-right:1px dashed black;float:left;">
						<h2 style="text-align:center;"><%= count %></h2>
					</div>
					<div style="width:349px;border-right:1px dashed black;float:left;">
						<h2 style="text-align:center;"><%= item.getItemName() %></h2>
					</div>
					<div style="width:99px;border-right:1px dashed black;float:left;">
						<h2 style="text-align:center;"><%= item.getItemStock() %></h2>
					</div>
					<div style="width:99px;border-right:1px dashed black;float:left;">
						<h2 style="text-align:center;"><%= item.getItemPrice() + "$" %></h2>
					</div>
					<div style="width:100px;float:left;">
						<h2 style="text-align:center;">
							<input type="text" style="width:20px;margin: 5px 15px;font-size:15px;" value="<%= map.get(i) %>" name="<%= i %>" />
						</h2>
					</div>
				</div>
				<%
			}
			%>
			<div style="width:700px;border-top:1px solid black;float:left;">
				<div style="width:100px;border-right:1px dashed black;float:right;margin-right:100px;">
					<h3 style="text-align:center;"><%= basket.getBasketValue() %>$</h2>
				</div>
				<div style="width:130px;border-right:1px dashed black;float:right;">
					<h3 style="text-align:center;">A total of</h2>
				</div>
			</div>
			<div style="float:right;margin:20px;">
				<input type="submit" value="Update" style="font-size:17px;padding:15px 7px;" />
			</div>
			</form>
			<div style="float:right;margin:20px;">
				<button type="button" onclick="window.location.href='checkout.do'" style="font-size:17px;padding:15px 7px;">Buy</button>
			</div>
		<% } %>
 	</div>
<%@include file="parts/footer.jsp" %>